
//
//  FYEmioticonViewCell.swift
//  dugeweibo
//
//  Created by pelesys on 16/8/10.
//  Copyright © 2016年 杜方宜. All rights reserved.
//

import UIKit

class FYEmioticonViewCell: UICollectionViewCell {
   // MARK:-懒加载属性
    private lazy var emotionBtn : UIButton = UIButton()
    // MARK:-定义的属性
    var emotion : FYEmotion? {
        didSet{
            guard let emotion = emotion else {
                return
            }
            //1.设置emotionBtn的内容
            emotionBtn.setImage(UIImage(contentsOfFile : emotion.pngPath ?? ""), for: .normal)
            emotionBtn.setTitle(emotion.emojiCode, for: .normal)
            //2.设置删除按钮
            if emotion.isRemove {
                emotionBtn.setImage(UIImage(named: "compose_emotion_delete"),  for: .normal)
            }
        }
    }
    // MARK:-重写构造函数
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
// MARK:-设置UI界面内容
extension FYEmioticonViewCell{
    private func setupUI(){
        //1.添加子控件
        contentView.addSubview(emotionBtn)
        //2.设置btn的frame
        emotionBtn.frame = contentView.bounds
        //3.设置btn属性
        emotionBtn.isUserInteractionEnabled = false
        emotionBtn.titleLabel?.font = UIFont.systemFont(ofSize: 32)
    }
}
